<?php
$this->breadcrumbs = array(
	'收款账',
);

if (Yii::app()->user->checkAccess('accountManage')) {
	$this->userActions = array(
		array(
			'label' => '新建收款账',
			'url' => array(
				'create'
			)
		),
		array(
			'label' => '管理收款账',
			'url' => array(
				'admin'
			)
		),
	);
}
Yii::app()->clientScript
->registerScript('search-account-receivable',
		"
var reloadStatistic=function(){
        var loading='努力计算中...';
        $('#account-receivable-result-statistic-total-price').html(loading);
        $('#account-receivable-result-statistic-max-price').html(loading);
        $('#account-receivable-result-statistic-min-price').html(loading);
        jQuery.post( '" . $this->createUrl('indexStatistic')
. "', $('#account-receivable-search-form').serialize(),function(data, textStatus, jqXHR){
console.log(data);
                $('#account-receivable-result-statistic-total-price').html(data.totalPrice);
        $('#account-receivable-result-statistic-max-price').html(data.maxPrice);
        $('#account-receivable-result-statistic-min-price').html(data.minPrice);
        }, 'json' )
};

$('#account-receivalbe-search-button').click(function(){
        $.fn.yiiListView.update('account-receivable-list', {
                data: $('#account-receivable-search-form').serialize()
        });
        reloadStatistic();
        return false;
});
reloadStatistic();
");
?>

<h1>收款账</h1>
<div class="form">
<?php $form = $this
	->beginWidget('CActiveForm',
		array(
			'id' => 'account-receivable-search-form',
			'action' => Yii::app()->createUrl($this->route),
			'method' => 'get',
		));
?>

	<?php echo $form->errorSummary($searchModel); ?>
<fieldset>
<legend>搜索条件</legend>

	<div class="span-8">
		<?php echo $form->labelEx($searchModel, 'projectId'); ?>
		<?php $this->widget('widgets.project.JProjectSelector',
				array(
					'model' => $searchModel,
					'attribute' => 'projectId',
				));
		?>
	</div>
	<div class="span-10">
		<?php echo $form->labelEx($searchModel, 'receiveDateMin'); ?>
		<?php $this
			->widget('zii.widgets.jui.CJuiDatePicker',
				array(
					'model' => $searchModel,
					'attribute' => 'receiveDateMin',
				));
		?> - 
		<?php $this
			->widget('zii.widgets.jui.CJuiDatePicker',
				array(
					'model' => $searchModel,
					'attribute' => 'receiveDateMax',
				));
		?>
	</div>
	<div class="clear"></div>
	<div class="span-18">
		<?php echo $form->labelEx($searchModel, 'keyword'); ?>
		<?php echo $form->textField($searchModel, 'keyword', array(
				'size' => 20
			));
		?>
	</div>
	<div class="clear"></div>
	<div class="span-18">
		<?php echo $form->labelEx($searchModel, 'priceMin'); ?>
		<?php echo $form->textField($searchModel, 'priceMin', array(
				'size' => 10
			));
		?> - <?php echo $form->textField($searchModel, 'priceMax', array(
					 'size' => 10
				 ));
			 ?>
	</div>

	<div class="row buttons">
		<?php echo CHtml::submitButton('搜索', array(
			'id' => 'account-receivalbe-search-button'
		)); ?>
	</div>

</fieldset>
<?php $this->endWidget(); ?>
</div>
<div id="account-receivable-result-statistic">
        <div id="account-receivable-statistic-title">统计</div>
        <div class="span-2">总金额：</div>
        <div id="account-receivable-result-statistic-total-price" class="span-3">努力计算中.....</div>
        <div class="span-2">单笔最多：</div>
        <div id="account-receivable-result-statistic-max-price" class="span-3">努力计算中.....</div>
        <div class="span-2">单笔最少：</div>
        <div id="account-receivable-result-statistic-min-price" class="span-3">努力计算中.....</div>
        <div class="clear"></div>
</div>
<?php $this
	->widget('zii.widgets.CListView',
		array(
			'id'=>'account-receivalbe-list',
			'dataProvider' => $dataProvider,
			'itemView' => '_view',
			'separator'=>'<div class="list-item-separator"></div>',
			'sortableAttributes' => array(
				'createTime',
				'receiveDate',
				'token',
			),
		));
?>
